package com.java.tutorials.jdk7.fileoperation;

import com.java.tutorials.Constants;

import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

/**
 * Created by xuzhike on 2016/1/25.
 * http://www.java2s.com/Code/Java/JDK-7/CopyingFilewithFilescopymethod.htm
 * Copying File with Files.copy method
 */
public class CopyingFilewithFilescopymethod {
    public static void main(String[] args) throws Exception {
        Path newFile = FileSystems.getDefault().getPath(Constants.TEST_PATH+"newFile.txt");
        Path copiedFile = FileSystems.getDefault().getPath(Constants.TEST_PATH+
                "copiedFile.txt");

        Files.createFile(newFile);
        System.out.println("File created successfully!");
        Files.copy(newFile, copiedFile);
        System.out.println("File copied successfully!");
        Files.copy(newFile, copiedFile, StandardCopyOption.REPLACE_EXISTING);

    }
}
